package com.Register.controller.user;

import com.Register.dto.SkillDocumentPageQueryDTO;
import com.Register.result.PageResult;
import com.Register.result.Result;
import com.Register.service.SkillDocumentService;
import com.Register.vo.SkillDocumentVO;
import com.fasterxml.jackson.core.JsonProcessingException;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("appletDocumentController")
@RequestMapping("/applet/user/skill")
@Tag(name = "小程序端-技能培训接口")
@Slf4j
public class SkillDocumentController {
    @Resource
    private SkillDocumentService skillDocumentService;

    @Operation(summary = "用户分页")
    @GetMapping("/getActive")
    public PageResult getActiveSkillDocument(@ParameterObject SkillDocumentPageQueryDTO skillDocumentPageQueryDTO) throws JsonProcessingException{
        return skillDocumentService.getActiveSkillDocument(skillDocumentPageQueryDTO);
    }

    @Operation(summary = "用户点击查看文章")
    @GetMapping("/view/{id}")
    public Result<SkillDocumentVO> viewSkillDocument(@PathVariable("id")Long id) throws JsonProcessingException {
        return Result.success(skillDocumentService.viewDoc(id));
    }
}
